package com.chenjiagou.ordertickets.service.impl;

import com.chenjiagou.ordertickets.entity.Booking;
import com.chenjiagou.ordertickets.dao.BookingDao;
import com.chenjiagou.ordertickets.service.BookingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (Booking)表服务实现类
 *
 * @author makejava
 * @since 2025-06-27 08:55:52
 */
@Service("bookingService")
public class BookingServiceImpl implements BookingService {
    @Resource
    private BookingDao bookingDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Booking queryById(Long id) {
        return this.bookingDao.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param booking 实例对象
     * @return 实例对象
     */
    @Override
    public Booking insert(Booking booking) {
        this.bookingDao.insert(booking);
        return booking;
    }

    /**
     * 修改数据
     *
     * @param booking 实例对象
     * @return 实例对象
     */
    @Override
    public Booking update(Booking booking) {
        this.bookingDao.update(booking);
        return this.queryById(booking.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.bookingDao.deleteById(id) > 0;
    }
}
